﻿
<style>
    .tablediv {
        margin: 0 auto;
    }
</style>

<div class="tablediv">
    <table id="recordTable" lay-filter="recordTable"></table>
</div>


<script type="text/html" id="mybar">
    <a class="layui-btn layui-btn-warm layui-btn-xs" lay-event="detail" style="border-radius: 6px;height: 26px;width: 56px;line-height: 26px">查看</a>
</script>

<script>
    layui.use(['table'],
        function() {
            var table = layui.table;

            table.render({
                elem: '#recordTable',
                height: 312,
                url: '/api/record/table', //数据接口
                where: {searchString:''}
                ,
                page: true //开启分页
                ,
                cols: [
                    [//表头
                        { field: 'id', title: 'ID', width: 80, hide: true, fixed: 'left' },
                        { field: 'name', title: '姓名', width: 280 }, { field: 'score', title: '综合成绩', width: 230 },
                        { toolbar: '#mybar', title: '操作', width: 276, align: 'center' }
                    ]
                ]
            });

            table.on('tool(recordTable)',
                function(obj) {
                    var data = obj.data;
                    window.open(`/Record/Detail?tid=${data.id}`);
                });
        });

</script>